import { Component, OnInit } from '@angular/core';
import {LocalDataSource} from "ng2-smart-table";
import {RoleService} from "../../share/services/role.service";

@Component({
  selector: 'app-role',
  templateUrl: './role.component.html',
  styleUrls: ['./role.component.css']
})
export class RoleComponent implements OnInit {
  settings
  source: LocalDataSource;
  constructor(private roleService: RoleService) {
    this.source = new LocalDataSource();
  }

  ngOnInit() {
    console.debug('RoleComponent init')
    this.settings = {
      selectMode: 'multi',
      hideSubHeader: true,
      noDataMessage: '没有数据',
      editable: false,
      attr: {
        class: 'table table-striped table-bordered'
      },
      actions: {
        columnTitle: '操作',
        add: false,
        edit: false,
        delete: true,
        position: 'right',
      },
      delete: {
        deleteButtonContent: '删除',
        confirmDelete: true,
      },
      page: {
        display: true,
        perPage: 10,
      },
      columns: {
        roleId: {
          title: '角色ID',
        },
        roleName: {
          title: '角色名',
        },
      }
    }
    this.loadData()
  }
  loadData(){
    this.roleService.list().subscribe(
      data => {
        this.source.load(data)
      }
    )
  }
  userRowSelect($event){
    console.debug($event)
  }
  mouseover($event){
    console.debug($event)
  }

}
